﻿using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;
using Microsoft.Practices.Unity;
using DreamBuilder.UI.UserControls.DataAccess.Services;
using System.Collections.Generic;
using System.Threading;
using DreamBuilder.DictionaryAccess;
using DreamBuilder.Common;
using EPlanet.Web.UI.WebControls;


namespace DreamBuilder.UI.UserControls
{

    public delegate void SPVoucherListRowCommandEventHandler(object sender, GridViewCommandEventArgs e);
    public delegate void SPVoucherListRowEventHandler(object sender, GridViewRowEventArgs e);
    public delegate void SPVoucherListRowDeletingEventHandler(object sender, GridViewDeleteEventArgs e);
    public delegate void SPVoucherListColumnSortingEventHandler(object sender, GridViewSortEventArgs e);


    public partial class SPageList : ControlBase
    {

        #region 单据列表字段
        /// <summary>
        ///  要进行委托的DataGrid控件的事件
        /// </summary>
        public event SPVoucherListRowCommandEventHandler SPVoucherListRowCommand;
        public event SPVoucherListRowEventHandler SPVoucherListRowDataBound;
        public event SPVoucherListRowDeletingEventHandler SPVoucherListRowDeleting;
        public event SPVoucherListColumnSortingEventHandler SPVoucherListColumnSorting;

        //Add by 陈杨 2011-4-18 16:09 增加绑定列按钮事件
        public event ClickedEventHandler BoundCommand = null;

        protected static readonly object SearchEvent = new object();
        System.Collections.Generic.List<CVoucherListItemInfo> voucherListItems;
        protected UCSearch ucSearch;
        private bool bDoSearch = false;
        /// <summary>
        /// 为了减少改动量保留以前的分页参数
        /// </summary>
        public Wuqi.Webdiyer.AspNetPager pager = new Wuqi.Webdiyer.AspNetPager();

        #endregion

        #region 单据列表的属性

        [Dependency]
        public SPageListDAL UCListDALService { get; set; }

        /// <summary>
        /// 单据列表编号
        /// </summary>
        public string VoucherID
        {
            get
            {
                object obj = ViewState["VoucherID"];
                return (obj == null) ? "" : (string)obj;
            }
            set { ViewState["VoucherID"] = value; }
        }

        /// <summary>
        /// 查询控件传递过来的Where子句
        /// </summary>
        public string SearchWhereSql
        {
            get
            {
                object obj = ViewState["SearchWhereSql"];
                return (obj == null) ? "" : (string)obj;
            }
            set { ViewState["SearchWhereSql"] = value; }
        }

        public bool DoSearch
        {
            get
            {
                return bDoSearch;
            }
            set
            {
                bDoSearch = value;
            }
        }

        /// <summary>
        /// 列表筛选条件
        /// </summary>
        public string FilterSqlWhere
        {
            get
            {
                object obj = ViewState["vFilterSqlWhere"];
                return (obj == null) ? "" : (string)obj;
            }
            set { ViewState["vFilterSqlWhere"] = value; }
        }

        /// <summary>
        /// 列表当前页的数据
        /// </summary>
        public DataTable CurrentPageData
        {
            get
            {
                object obj = ViewState["dtList"];
                return (obj == null) ? null : (DataTable)obj;
            }
            set { ViewState["dtList"] = value; }
        }

        /// <summary>
        /// 列表当前页的数据
        /// </summary>
        public string Title
        {
            get
            {
                object obj = ViewState["Title"];
                return (obj == null) ? "" : (string)obj;
            }
            set { ViewState["Title"] = value; }
        }

        /// <summary>
        /// 是否需要查询控件
        /// </summary>
        public bool NeedSearch
        {
            set
            {
                this.ucSearch.Visible = value;
            }
        }

        /// <summary>
        /// 是否显示标题
        /// </summary>
        public bool ShowTitle
        {
            get
            {
                object obj = ViewState["ShowTitle"];
                return (obj == null) ? true : System.Convert.ToBoolean(ViewState["ShowTitle"].ToString());
            }
            set { ViewState["ShowTitle"] = value; }
        }


        /// <summary>
        /// 显示选择框号,默认显示
        /// </summary>
        public bool ShowListCheck
        {
            get
            {
                object obj = ViewState["ShowListCheck"];
                return (obj == null) ? true : System.Convert.ToBoolean(ViewState["ShowListCheck"].ToString());
            }
            set { ViewState["ShowListCheck"] = value; }
        }



        /// <summary>
        /// 显示序列号,默认显示
        /// </summary>
        public bool ShowSequence
        {
            get
            {
                object obj = ViewState["ShowSequence"];
                return (obj == null) ? true : System.Convert.ToBoolean(ViewState["ShowSequence"].ToString());
            }
            set { ViewState["ShowSequence"] = value; }
        }


        /// <summary>
        /// 显示审核命令列，默认隐藏
        /// </summary>
        public bool ShowApproveCommand
        {
            get
            {
                object obj = ViewState["ShowApproveCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowApproveCommand"].ToString());
            }
            set { ViewState["ShowApproveCommand"] = value; }

        }

        /// <summary>
        /// 显示普通命令列
        /// </summary>
        public bool ShowCommonCommand
        {
            get
            {
                return ViewState["ShowCommonCommand"] != null ? Convert.ToBoolean(ViewState["ShowCommonCommand"]) : false;
            }
            set { ViewState["ShowCommonCommand"] = value; }
        }

        /// <summary>
        /// 设置或获取普通命令列的标题
        /// </summary>
        public string CommonCommandTitle
        {
            get
            {
                return ViewState["CommonCommandTitle"] != null ? ViewState["CommonCommandTitle"].ToString() : "命令列";
            }
            set { ViewState["CommonCommandTitle"] = value; }
        }

        /// <summary>
        /// 用户自定义排序
        /// </summary>
        public string UserSortExpression
        {
            set
            {
                ViewState["SortExpression"] = value;
            }
        }

        /// <summary>
        /// 显示弃审命令列，默认隐藏
        /// </summary>
        public bool ShowUnApproveCommand
        {
            get
            {
                object obj = ViewState["ShowUnApproveCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowUnApproveCommand"].ToString());
            }
            set { ViewState["ShowUnApproveCommand"] = value; }
        }

        /// <summary>
        /// 显示提交命令列，默认隐藏
        /// </summary>
        public bool ShowSubmitCommand
        {
            get
            {
                object obj = ViewState["ShowSubmitCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowSubmitCommand"].ToString());
            }
            set { ViewState["ShowSubmitCommand"] = value; }
        }

        /// <summary>
        /// 显示提交命令列，默认隐藏
        /// </summary>
        public bool ShowDownloadCommand
        {
            get
            {
                object obj = ViewState["ShowDownloadCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowDownloadCommand"].ToString());
            }
            set { ViewState["ShowDownloadCommand"] = value; }
        }
        /// <summary>
        /// 显示上移命令列，默认隐藏
        /// </summary>
        public bool ShowMoveUpCommand
        {
            get
            {
                object obj = ViewState["ShowMoveUpCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowMoveUpCommand"].ToString());

            }
            set { ViewState["ShowMoveUpCommand"] = value; }
        }
        /// <summary>
        /// 显示下移命令列，默认隐藏
        /// </summary>
        public bool ShowMoveDownCommand
        {
            get
            {
                object obj = ViewState["ShowMoveDownCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowMoveDownCommand"].ToString());

            }
            set { ViewState["ShowMoveDownCommand"] = value; }
        }

        /// <summary>
        /// 显示打印报表命令列，默认隐藏
        /// </summary>
        public bool ShowPrintCommand
        {
            get
            {
                object obj = ViewState["ShowPrintCommand"];
                return (obj == null) ? false : System.Convert.ToBoolean(ViewState["ShowPrintCommand"].ToString());
            }
            set { ViewState["ShowPrintCommand"] = value; }
        }

        /// <summary>
        /// 是否显示浏览命令列,默认显示
        /// </summary>
        public bool ShowViewCommand
        {
            get
            {
                object obj = ViewState["ShowViewCommand"];
                return (obj == null) ? true : System.Convert.ToBoolean(ViewState["ShowViewCommand"].ToString());
            }
            set { ViewState["ShowViewCommand"] = value; }
        }

        /// <summary>
        /// 是否显示修改命令列,默认显示
        /// </summary>

        public bool ShowEditCommand
        {
            get
            {
                object obj = ViewState["ShowEditCommand"];
                return (obj == null) ? true : System.Convert.ToBoolean(ViewState["ShowEditCommand"].ToString());
            }
            set { ViewState["ShowEditCommand"] = value; }
        }

        /// <summary>
        /// 是否显示删除命令列,默认显示
        /// </summary>
        public bool ShowDeleteCommand
        {
            get
            {
                object obj = ViewState["ShowDeleteCommand"];
                return (obj == null) ? true : System.Convert.ToBoolean(ViewState["ShowDeleteCommand"].ToString());
            }
            set { ViewState["ShowDeleteCommand"] = value; }

        }


        /// <summary>
        /// 显示每页的记录数
        /// </summary>
        public int ShowRecordsCount
        {
            get
            {
                object obj = ViewState["ShowRecordsCount"];
                return (obj == null) ? int.Parse(System.Configuration.ConfigurationManager.AppSettings["PageSize"]) : (int)ViewState["ShowRecordsCount"];
            }
            set { ViewState["ShowRecordsCount"] = value; }
        }

        /// <summary>
        /// 排序方向屬性
        /// </summary>
        public SortDirection GridViewSortDirection
        {
            get
            {
                if (ViewState["sortDirection"] == null)
                {
                    ViewState["sortDirection"] = SortDirection.Ascending;
                }
                return (SortDirection)ViewState["sortDirection"];
            }
            set
            {
                ViewState["sortDirection"] = value;
            }
        }

        /// <summary>
        /// 设置加密列
        /// </summary>
        public string EncryptColumnFields
        {
            get
            {
                object obj = ViewState["EncryptColumnFields"];
                return (obj == null) ? "" : (string)obj;
            }
            set { ViewState["EncryptColumnFields"] = value; }
        }

        /// <summary>
        /// 跳转到的页码
        /// </summary>
        private int GotoPage
        {
            get
            {
                if (ViewState["GotoPage"] != null)
                {
                    return int.Parse(ViewState["GotoPage"].ToString());
                }
                else
                {
                    return 0;
                }
            }
            set
            {
                ViewState["GotoPage"] = value;
            }
        }

        /// <summary>
        /// 总记录数 Add By WangBo 20120520 保存总记录数
        /// </summary>
        private int RecordCount
        {
            get
            {
                if (ViewState["RecordCount"] != null)
                {
                    return int.Parse(ViewState["RecordCount"].ToString());
                }
                else
                {
                    return 0;
                }
            }
            set
            {
                ViewState["RecordCount"] = value;
            }
        }

        /// <summary>
        /// 页索引 Add By WangBo 20120520 保存页索引
        /// </summary>
        private int GPageIndex
        {
            get
            {
                if (ViewState["PageIndex"] != null)
                {
                    return int.Parse(ViewState["PageIndex"].ToString());
                }
                else
                {
                    return 0;
                }
            }
            set
            {
                ViewState["PageIndex"] = value;
            }
        }


        #endregion

        #region 单据列表PageLoad

        protected void Page_Load(object sender, System.EventArgs e)
        {
            // 在此处放置用户代码以初始化页面
            if (string.IsNullOrEmpty(VoucherID))
            {
                this.gvList.Visible = false;
                //this.pager.Visible = false;

                return;
            }
            ControlPath = "UserControls/SPageList";
            ucSearch.VoucherID = this.VoucherID;
            //设置Gridview分页的ViewState 防止刷新页面导致跳转页数消失

            if (this.gvList.BottomPagerRow != null)
            {
                TextBox t = (TextBox)this.gvList.BottomPagerRow.FindControl("txtPageInex");
                if (t != null && t.Text != string.Empty)
                {
                    int gotopage = 1;
                    int.TryParse(t.Text, out gotopage);
                    GotoPage = gotopage > 0 ? gotopage - 1 : gotopage;//存储的是页码索引值，要在输入的值上减去1
                }
            }
            //重新构造Gridview的结构
            SetVoucherListStruct();
            if (!Page.IsPostBack)
            {
                ViewState["SortExpression"] = "";
                ViewState["sort"] = "desc";
                if (ShowTitle == true)
                {
                    if (string.IsNullOrEmpty(Title))
                    {
                        this.litTitle.Text = GetVoucherListTitle(VoucherID);
                    }
                    else
                    {
                        this.litTitle.Text = Title;
                    }
                }

            }
            BindVoucherListData();


        }

        #endregion

        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        ///		设计器支持所需的方法 - 不要使用代码编辑器
        ///		修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.gvList.RowCommand += new GridViewCommandEventHandler(gvList_RowCommand);
            this.gvList.RowDeleting += new GridViewDeleteEventHandler(gvList_RowDeleting);
            this.gvList.Sorting += new GridViewSortEventHandler(gvList_Sorting);
            this.gvList.RowDataBound += new GridViewRowEventHandler(gvList_RowDataBound);
            this.gvList.RowCreated += new GridViewRowEventHandler(gvList_RowCreated);
            this.gvList.RowEditing += new GridViewEditEventHandler(gvList_RowEditing);
            this.gvList.PageIndexChanging += new GridViewPageEventHandler(gvList_PageIndexChanging);
            //this.pager.PageChanged += new EventHandler(pager_PageChanged);
            this.ucSearch.SearchEvent += new SearchHandle(UCSearch1_SearchEvent);
        }

        /// <summary>
        /// 分页事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GetListData(GotoPage);
            this.gvList.PageIndex = GotoPage;
            this.gvList.DataSource = (DataTable)ViewState["dtList"];
            //this.GotoPage= e.NewPageIndex;
            //this.gvList.PageIndex = e.NewPageIndex;
            this.gvList.DataBind();
        }

        void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "goto")
            {
                if (this.gvList.PageIndex < this.gvList.PageCount)
                {
                    int index = 0;
                    TextBox t = ((TextBox)gvList.BottomPagerRow.FindControl("txtPageInex"));
                    if (t.Text != string.Empty)
                    {
                        int.TryParse(t.Text, out index);
                        this.GotoPage = index - 1;
                    }
                    GridViewPageEventArgs args = new GridViewPageEventArgs(this.GotoPage);
                    gvList_PageIndexChanging(null, args);
                }

            }
            else if (e.CommandName != "Page")
            {
                if (SPVoucherListRowCommand != null)
                {
                    SPVoucherListRowCommand(sender, e);
                }
            }
            else
            {
                if (e.CommandArgument.ToString() == "First")
                {
                    this.GotoPage = 0;
                    GridViewPageEventArgs args = new GridViewPageEventArgs(pager.CurrentPageIndex);
                    gvList_PageIndexChanging(null, args);
                }
                if (e.CommandArgument.ToString() == "Prev")
                {
                    this.GotoPage = this.GotoPage - 1;
                    GridViewPageEventArgs args = new GridViewPageEventArgs(pager.CurrentPageIndex);
                    gvList_PageIndexChanging(null, args);
                }
                if (e.CommandArgument.ToString() == "Next")
                {
                    this.GotoPage += 1;
                    GridViewPageEventArgs args = new GridViewPageEventArgs(pager.CurrentPageIndex);
                    gvList_PageIndexChanging(null, args);
                }
                if (e.CommandArgument.ToString() == "Last")
                {
                    this.GotoPage = gvList.PageCount - 1;
                    GridViewPageEventArgs args = new GridViewPageEventArgs(pager.CurrentPageIndex);
                    gvList_PageIndexChanging(null, args);
                }
            }
        }

        void gvList_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (SPVoucherListRowDeleting != null)
            {
                SPVoucherListRowDeleting(sender, e);
            }
        }

        void gvList_Sorting(object sender, GridViewSortEventArgs e)
        {
            string sort = string.Empty;
            if (ViewState["SortExpression"].ToString() == e.SortExpression.ToString())
            {
                if (ViewState["sort"].ToString() == "asc")
                {
                    sort = "desc";
                }
                else
                {
                    sort = "asc";
                }
            }
            else
            {
                if (ViewState["sort"].ToString() == "asc")
                {
                    sort = "desc";
                }
                else
                {
                    sort = "asc";
                }
            }
            ViewState["sort"] = sort;
            ViewState["SortExpression"] = e.SortExpression;
            if (SPVoucherListColumnSorting != null)
            {
                SPVoucherListColumnSorting(this, e);
            }
            ViewState["dtList"] = null;
            SetVoucherListStruct();
            BindVoucherListData();
        }

        void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //if (e.Row.RowType == DataControlRowType.DataRow)
            //{
            //    foreach (TableCell cell in e.Row.Cells)
            //    {
            //        if (cell.Controls.Count > 0)
            //        {
            //            LinkButton linkButton = cell.Controls[0] as LinkButton;
            //            if (linkButton != null)
            //            {
            //                linkButton.Attributes.Add("class", "table_button");
            //                linkButton.Attributes.Add("onmouseover", "this.className='table_buttonOver'");
            //                linkButton.Attributes.Add("onmouseout", "this.className='table_button'");
            //            }
            //        }
            //    }
            //}                   
            if (SPVoucherListRowDataBound != null)
            {
                SPVoucherListRowDataBound(sender, e);
            }
        }

        void gvList_RowCreated(object sender, GridViewRowEventArgs e)
        {
            //if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)
            //{
            //    e.Row.Attributes.Add("onclick", "javascript:return ClickSetColor(this);");
            //    e.Row.Attributes.Add("onmouseover", "javascript:MouseOnSetColor(this);");
            //    e.Row.Attributes.Add("onmouseout", "javascript:MouseOutCancelColor(this);");
            //}
        }


        //Add by 陈杨 2011-4-18 16:09 增加绑定列按钮事件
        void boundLink_CommandClick(object toSender, ClickEventArgs e)
        {
            if (this.BoundCommand != null)
            {
                this.BoundCommand(toSender, e);
            }
        }

        public event EventHandler SearchClick
        {
            add
            {
                base.Events.AddHandler(SPageList.SearchEvent, value);
            }
            remove
            {
                base.Events.RemoveHandler(SPageList.SearchEvent, value);
            }
        }

        private void UCSearch1_SearchEvent(object sender, EventArgs e)
        {
            DoSearch = true;
            SearchWhereSql = ucSearch.WhereSql;
            if (base.Events != null)
            {
                EventHandler handler = (EventHandler)base.Events[SPageList.SearchEvent];
                if (handler != null)
                {
                    handler(this, e);
                }
            }
            RefreshList();
        }
        #endregion

        #region 构建GridView的结构

        private void SetListStyle()
        {
            //***added by L.Tang 2011-6-1 增加列表换行*******
            gvList.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
            //**********************************************

            gvList.AutoGenerateColumns = false;
            gvList.AllowSorting = true;
            gvList.HeaderStyle.CssClass = "LT-table-header";
            gvList.AlternatingRowStyle.CssClass = "LT-table-alterRow";
            gvList.RowStyle.CssClass = "LT-table-row";
            gvList.SelectedRowStyle.CssClass = "LT-table-selectRow";

        }

        private void AddTemplateColumn(string sHeadText, string sImageUrl, string sID)
        {
            TemplateField templateField = new TemplateField();
            templateField.HeaderText = CResManager.GetPublicString("Button", sHeadText).Replace("[", "").Replace("]", "");
            templateField.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            templateField.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            templateField.HeaderStyle.Width = 40;
            templateField.HeaderStyle.CssClass = "LT-table-header-td";
            templateField.ItemStyle.Width = GetButtonCellWidth();
            templateField.ItemStyle.Wrap = false;
            sImageUrl = Request.ApplicationPath + sImageUrl;
            templateField.ItemTemplate = new ListTemplateImageButton(sImageUrl, sID, sID);
            gvList.Columns.Add(templateField);
        }

        private void AddITemplateCheck()
        {
            bool bStatus = ViewState["STATUS"] == null ? false : (bool)ViewState["STATUS"];
            TemplateField templateField = new TemplateField();
            templateField.HeaderStyle.Wrap = false;
            templateField.HeaderStyle.Width = Unit.Percentage(4);
            templateField.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            templateField.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            templateField.HeaderTemplate = new ListTemplateCheckHeader(bStatus);
            templateField.ItemTemplate = new ListTemplateCheckColumn();
            gvList.Columns.Add(templateField);
        }

        private void AddNumberIndexColumn()
        {
            BoundField boundField = new BoundField();
            boundField.DataField = "NumberIndex";
            boundField.HeaderText = GetString("sequence");
            boundField.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            boundField.HeaderStyle.Wrap = false;
            boundField.HeaderStyle.CssClass = "LT-table-header-td";
            boundField.ItemStyle.Width = 30;
            boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            boundField.ItemStyle.Wrap = false;
            gvList.Columns.Add(boundField);
        }

        private int GetButtonCellWidth()
        {
            int width;
            switch (Thread.CurrentThread.CurrentUICulture.Name.ToLower())
            {
                case "zh-cn":
                    width = 30;
                    break;
                case "en-us":
                    width = 35;
                    break;
                case "ru-ru":
                    width = 50;
                    break;
                default:
                    width = 40;
                    break;
            }
            return width;
        }

        private string GetVoucherMainTableCode()
        {
            VoucherTotalInfo voucherTotalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            if (voucherTotalInfo != null)
            {
                return voucherTotalInfo.MainTable;
            }
            return "";
        }

        private string GetVoucherMainTablePK()
        {
            string mainTableCode = GetVoucherMainTableCode();
            TableDicInfo tableDicInfo = DictionaryAccessFacade.GetTableDicInfo(mainTableCode);
            if (tableDicInfo != null)
            {
                return tableDicInfo.PrimaryField;
            }
            return "";

        }

        private void SetDataKeyField()
        {
            gvList.DataKeyNames = new string[] { GetVoucherMainTableCode() + "__" + GetVoucherMainTablePK() };
        }

        private void GetListItemList()
        {
            if (voucherListItems == null)
            {
                voucherListItems = DictionaryAccessFacade.GetSortedListItemsInfo(VoucherID);
            }
        }

        private SortData GetSortData()
        {
            SortData structSortData = new SortData();
            if (ViewState["SortExpression"] != null && ViewState["SortExpression"].ToString() != "")
            {
                structSortData.SortExpression = ViewState["SortExpression"].ToString();
                structSortData.Sort = ViewState["sort"].ToString();
            }
            return structSortData;
        }
        /// <summary>
        /// 构建GridView结构
        /// </summary>
        public void SetVoucherListStruct()
        {
            if (this.gvList.Columns.Count > 0)
            {
                gvList.Columns.Clear();
            }
            //SetListStyle();
            SetDataKeyField();
            //是否加选择列
            if (ShowListCheck == true)
            {
                AddITemplateCheck();
            }
            //是否加序号
            if (ShowSequence == true)
            {
                // AddNumberIndexColumn();
            }
            if (voucherListItems == null)
            {
                GetListItemList();
            }
            voucherListItems.ForEach<CVoucherListItemInfo>(
            delegate(CVoucherListItemInfo pVoucherListItemInfo)
            {
                if (pVoucherListItemInfo.ItemType != LISTITEMTYPE.TYPE_BoundLinkColumn)
                {
                    DataControlField dataControlField = DataControlFieldFactory.Create(pVoucherListItemInfo, GetSortData());
                    gvList.Columns.Add(dataControlField);
                }
                else
                {
                    //Add by 陈杨 2011-4-18 16:09 增加绑定列按钮事件
                    TemplateField boundLinkFile = new TemplateField();
                    boundLinkFile.HeaderText = CResManager.GetPublicString("Button", pVoucherListItemInfo.TableCode + '.' + pVoucherListItemInfo.ItemCode);
                    boundLinkFile.HeaderStyle.HorizontalAlign = ControlCommon.GetAlignStyle(pVoucherListItemInfo.ArrangeType);
                    boundLinkFile.ItemStyle.HorizontalAlign = ControlCommon.GetAlignStyle(pVoucherListItemInfo.ArrangeType);
                    boundLinkFile.HeaderStyle.Width = Unit.Percentage(pVoucherListItemInfo.Width);
                    boundLinkFile.HeaderStyle.CssClass = "LT-table-header-td";
                    boundLinkFile.ItemStyle.Width = Unit.Percentage(pVoucherListItemInfo.Width);
                    boundLinkFile.ItemStyle.Wrap = true;
                    boundLinkFile.HeaderStyle.Wrap = true;
                    string sImageUrl = Request.ApplicationPath + pVoucherListItemInfo.NavigateURL;
                    ListTemplateBoundLink boundLink = (ListTemplateBoundLink)DataControlFieldFactory.CreateBoundLink(pVoucherListItemInfo, sImageUrl);
                    boundLink.CommandClick += new ClickedEventHandler(boundLink_CommandClick);
                    boundLinkFile.ItemTemplate = boundLink;
                    gvList.Columns.Add(boundLinkFile);
                }
            }
            );
            string headText = "";
            string imageUrl = "";
            string id = "";
            if (ShowCommonCommand == true)
            {
                headText = CommonCommandTitle;
                imageUrl = "/Images/Grid/edit3.jpg";
                id = "CommonCommand";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowSubmitCommand == true)
            {
                headText = "btnSubmit";
                imageUrl = "/Images/Grid/GridSubmit.gif";
                id = "Submit";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowApproveCommand == true)
            {
                headText = "btnApprove";
                imageUrl = "/Images/Grid/GridApprove.gif";
                id = "Approve";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowUnApproveCommand == true)
            {
                headText = "btnUnApprove";
                imageUrl = "/Images/Grid/GridUnApprove.gif";
                id = "UnApprove";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowPrintCommand == true)
            {
                headText = "btnPrint";
                imageUrl = "/Images/Grid/GridPrint.gif";
                id = "Print";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowViewCommand == true)
            {
                headText = "btnView";
                imageUrl = "/Images/Grid/GridView.png";
                id = "View";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowEditCommand == true)
            {
                headText = "btnEdit";
                imageUrl = "/Images/Grid/GridEdit.png";
                id = "Edit";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowDeleteCommand == true)
            {
                headText = "btnDelete";
                imageUrl = "/Images/Grid/GridDelete.png";
                id = "Delete";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowDownloadCommand == true)
            {
                headText = "btnDownload";
                imageUrl = "/Images/Grid/GridDownLoad.gif";
                id = "Download";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowMoveUpCommand == true)
            {
                headText = "btnMoveUp";
                imageUrl = "/Images/Grid/OA_Sys_Up.gif";
                id = "MoveUp";
                AddTemplateColumn(headText, imageUrl, id);
            }
            if (ShowMoveDownCommand == true)
            {
                headText = "btnMoveDown";
                imageUrl = "/Images/Grid/OA_Sys_Down.gif";
                id = "MoveDown";
                AddTemplateColumn(headText, imageUrl, id);
            }


        }


        #endregion

        #region 向搭建好的GridView填充数据



        private string GetWhereSql()
        {
            string whereSql = "";
            string searchWhereSql = SearchWhereSql;//vSearchWhereSql;
            if (searchWhereSql.Length > 0)
            {
                whereSql += " AND " + searchWhereSql;
            }
            if (FilterSqlWhere.Length > 0)
            {
                whereSql += " AND (" + FilterSqlWhere + ")";
            }
            if (searchWhereSql.Length == 0
                && HttpContext.Current.Request["DoSearchSql"] != null
                && HttpContext.Current.Request["DoSearchSql"].Length > 0
                && DoSearch == false)
            {
                whereSql += "AND (" + System.Web.HttpContext.Current.Request.QueryString["DoSearchSql"].ToString() + ")";
            }
            return whereSql;
        }

        private string GetOrderSql(string orderSql)
        {
            if (ViewState["SortExpression"].ToString() != "")
            {
                return ViewState["SortExpression"].ToString() + " " + ViewState["sort"].ToString();
            }
            else
            {
                return orderSql;
            }
        }

        /// <summary>
        /// 获取列表数据
        /// </summary>
        private void GetListData()
        {
            if (voucherListItems == null)
            {
                this.GetListItemList();
            }
            VoucherTotalInfo totalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            string selectSql = "";
            string fromSql = "";
            if (string.IsNullOrEmpty(totalInfo.TableConnectSql))
            {
                fromSql = totalInfo.MainTable;
            }
            else
            {
                fromSql = totalInfo.TableConnectSql;
            }
            int columnIndex = 0;
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            voucherListItems.ForEach<CVoucherListItemInfo>(
            delegate(CVoucherListItemInfo voucherListItemInfo)
            {
                UCListDALService.GenerateListSql(voucherListItemInfo, ref selectSql, ref fromSql, ref columnIndex, dictionary);
            }
            );
            selectSql = selectSql.Substring(0, selectSql.Length - 1);
            string whereSql = GetWhereSql();
            string orderSql = GetOrderSql(totalInfo.OrderSql.ToString().Trim());
            //排序
            //int recordCount;
            //if (orderSql != string.Empty)
            //{
            //    whereSql = whereSql + " order by " + orderSql;
            //}
            //DataTable dtPageData = UCListDALService.SelectListPaged(selectSql, fromSql, whereSql, orderSql, "", pager.CurrentPageIndex, pager.PageSize, out recordCount, dictionary);

            DataTable dtPageData = UCListDALService.GetExportData(selectSql, fromSql, whereSql);
            pager.RecordCount = dtPageData.Rows.Count;
            //Add by 崔茂山 2010年11月22日11:04:45
            SetEncryptColumn(dtPageData);

            ViewState["dtList"] = dtPageData;
            BindVoucherListData();

        }

        /// <summary>
        /// 获取列表数据，根据页索引查询数据
        /// </summary>
        /// <param name="pageIndex">页索引</param>
        private void GetListData(int pageIndex)
        {
            if (voucherListItems == null)
            {
                this.GetListItemList();
            }
            VoucherTotalInfo totalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            string selectSql = "";
            string fromSql = "";
            if (string.IsNullOrEmpty(totalInfo.TableConnectSql))
            {
                fromSql = totalInfo.MainTable;
            }
            else
            {
                fromSql = totalInfo.TableConnectSql;
            }
            int columnIndex = 0;
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            voucherListItems.ForEach<CVoucherListItemInfo>(
            delegate(CVoucherListItemInfo voucherListItemInfo)
            {
                UCListDALService.GenerateListSql(voucherListItemInfo, ref selectSql, ref fromSql, ref columnIndex, dictionary);
            }
            );
            selectSql = selectSql.Substring(0, selectSql.Length - 1);
            string whereSql = GetWhereSql();
            string orderSql = GetOrderSql(totalInfo.OrderSql.ToString().Trim());
            //排序
            //int recordCount;
            //if (orderSql != string.Empty)
            //{
            //    whereSql = whereSql + " order by " + orderSql;
            //}
            //DataTable dtPageData = UCListDALService.SelectListPaged(selectSql, fromSql, whereSql, orderSql, "", pager.CurrentPageIndex, pager.PageSize, out recordCount, dictionary);

            // Edit By WangBo 20120520 修改分页查询
            int recordCount = 0;
            DataTable dtPageData = UCListDALService.GetExportData(selectSql, fromSql, whereSql, pageIndex, this.gvList.PageSize, out recordCount, orderSql);
            pager.RecordCount = dtPageData.Rows.Count;
            this.RecordCount = recordCount;
            //Add by 崔茂山 2010年11月22日11:04:45
            SetEncryptColumn(dtPageData);

            ViewState["dtList"] = dtPageData;

        }


        /// <summary>
        /// 获取列表数据
        /// </summary>
        public DataTable GetListData(int pagedif, string strsql_order)
        {
            if (voucherListItems == null)
            {
                this.GetListItemList();
            }
            VoucherTotalInfo totalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            string selectSql = "";
            string fromSql = "";
            if (string.IsNullOrEmpty(totalInfo.TableConnectSql))
            {
                fromSql = totalInfo.MainTable;
            }
            else
            {
                fromSql = totalInfo.TableConnectSql;
            }
            int columnIndex = 0;
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            voucherListItems.ForEach<CVoucherListItemInfo>(
            delegate(CVoucherListItemInfo voucherListItemInfo)
            {
                UCListDALService.GenerateListSql(voucherListItemInfo, ref selectSql, ref fromSql, ref columnIndex, dictionary);
            }
            );
            selectSql = selectSql.Substring(0, selectSql.Length - 1);
            string whereSql = GetWhereSql();
            string orderSql = strsql_order;
            if (orderSql == null) orderSql = GetOrderSql(totalInfo.OrderSql.ToString().Trim());

            //排序
            //int recordCount;
            //DataTable dtPageData = null;
            //if ((pager.CurrentPageIndex + pagedif) == 0)
            //{
            //     dtPageData = null;
            //}
            //else
            //{
            //     dtPageData = UCListDALService.SelectListPaged(selectSql, fromSql, whereSql, orderSql, "",
            //        pager.CurrentPageIndex + pagedif, pager.PageSize, out recordCount, dictionary);
            //}
            //int recordCount;
            //if (orderSql != string.Empty)
            //{
            //    whereSql = whereSql + " order by " + orderSql;
            //}
            //DataTable dtPageData = UCListDALService.SelectListPaged(selectSql, fromSql, whereSql, orderSql, "", pager.CurrentPageIndex, pager.PageSize, out recordCount, dictionary);
            int recordCount = 0;
            DataTable dtPageData = UCListDALService.GetExportData(selectSql, fromSql, whereSql, this.gvList.PageIndex, this.gvList.PageSize, out recordCount, orderSql);
            pager.RecordCount = dtPageData.Rows.Count;
            return dtPageData;
        }


        /// <summary>
        /// 显示数据(带分页控件)
        /// </summary>
        private void BindVoucherListData()
        {
            if (GotoPage != 0 && GotoPage >= gvList.PageCount)
            {
                GotoPage = gvList.PageCount - 1;
            }

            GetListData(GotoPage);
            gvList.RecordCount = this.RecordCount;
            gvList.PageIndex = GotoPage;
            gvList.DataSource = ((DataTable)ViewState["dtList"]);
            gvList.DataBind();
            if (this.gvList.Controls.Count != 0 && this.RecordCount > this.gvList.PageSize)
            {
                Control table = this.gvList.Controls[0];
                int count = table.Controls.Count;
                table.Controls[count - 1].Visible = true;
            }
            //SetAspNetPagerInfo(pager);
        }

        #endregion

        #region 根据主表主键获取所有表的记录信息集合，以DataSet形式传出
        /// <summary>
        /// 获取传出数据表的列类型
        /// </summary>
        /// <param name="emFieldType"></param>
        /// <returns></returns>
        private string GetDataTableColumnType(FIELDTYPE fieldType)
        {
            string type = string.Empty;
            switch (fieldType)
            {
                case FIELDTYPE.TYPE_Integer:
                    type = "System.Int32";
                    break;
                case FIELDTYPE.TYPE_Float:
                    type = "System.Decimal";
                    break;
                case FIELDTYPE.TYPE_Bool:
                    type = "System.Boolean";
                    break;
                case FIELDTYPE.TYPE_String:
                    type = "System.String";
                    break;
                case FIELDTYPE.TYPE_Date:
                    type = "System.DateTime";
                    break;
                case FIELDTYPE.TYPE_TimeStamp:
                    type = "System.String";
                    break;
                case FIELDTYPE.TYPE_Reference:
                    type = "System.String";
                    break;
                case FIELDTYPE.TYPE_Decimal:
                    type = "System.Decimal";
                    break;
                case FIELDTYPE.TYPE_Media:
                    type = "System.String";
                    break;
            }
            return type;
        }


        /// <summary>
        /// 产生DataSet的结构，将编辑控件用到的表的所有字段封装在DataSet中
        /// </summary>
        /// <returns></returns>
        private System.Data.DataSet GenerateDSStruct()
        {
            System.Data.DataSet dsInfo = new DataSet();
            VoucherTotalInfo voucherTotalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            if (voucherTotalInfo == null)
                return null;

            string tableCodes = voucherTotalInfo.TableCodes;
            foreach (string tableCode in System.Text.RegularExpressions.Regex.Split(tableCodes, ","))
            {
                System.Data.DataTable dtInfo = new DataTable(tableCode);
                DictionaryAccessFacade.GetSortedFieldsDicInfo(tableCode).ForSpecification<FieldDicInfo>(delegate(FieldDicInfo fieldDicInfo)
                {
                    DataColumn colName = new DataColumn(fieldDicInfo.FieldCode, Type.GetType(GetDataTableColumnType(fieldDicInfo.FieldType)));
                    dtInfo.Columns.Add(colName);
                },
                delegate(FieldDicInfo fieldDicInfo)
                {

                    TableDicInfo tableDicInfo = DictionaryAccessFacade.GetTableDicInfo(tableCode);
                    if (tableDicInfo == null)
                    {
                        return false;
                    }
                    string tablePK = tableDicInfo.PrimaryField;
                    if (fieldDicInfo.FieldCode == tablePK)
                    {
                        return true;
                    }
                    return false;
                }
                );
                DataColumn colRowstatus = new DataColumn("RowStatus", Type.GetType("System.String"));
                dtInfo.Columns.Add(colRowstatus);
                SetTablePrimaryKey(dtInfo);
                dsInfo.Tables.Add(dtInfo);
            }
            return dsInfo;
        }

        /// <summary>
        /// 给DataSet中的DataTable增加一个空行数据
        /// </summary>
        /// <returns></returns>
        private void AddDSNewRow(System.Data.DataSet dsInfo)
        {
            foreach (DataTable dtInfo in dsInfo.Tables)
            {
                DataRow drInfo = dtInfo.NewRow();
                drInfo[dtInfo.PrimaryKey[0]] = Guid.NewGuid().ToString();
                dtInfo.Rows.Add(drInfo);
            }
        }

        /// <summary>
        /// 产生字段选择语句，用于填充所选择的主键值对应的主表记录及其他表记录
        /// </summary>
        /// <returns></returns>
        private string GenerateFieldSelectSql()
        {
            string fieldSelectSql = "select ";
            VoucherTotalInfo voucherTotalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            string tableCodes = voucherTotalInfo.TableCodes;
            foreach (string tableCode in System.Text.RegularExpressions.Regex.Split(tableCodes, ","))
            {
                DictionaryAccessFacade.GetSortedFieldsDicInfo(tableCode).ForSpecification<FieldDicInfo>(delegate(FieldDicInfo fieldDicInfo)
                {
                    fieldSelectSql = fieldSelectSql + tableCode + "." + fieldDicInfo.FieldCode + " as \"" + tableCode + "." + fieldDicInfo.FieldCode + "\",";
                },
                delegate(FieldDicInfo fieldDicInfo)
                {
                    TableDicInfo tableDicInfo = DictionaryAccessFacade.GetTableDicInfo(tableCode);
                    if (tableDicInfo == null)
                    {
                        return false;
                    }
                    string tablePK = tableDicInfo.PrimaryField;
                    if (fieldDicInfo.FieldCode == tablePK)
                    {
                        return true;
                    }
                    return false;
                });
            }
            fieldSelectSql = fieldSelectSql.Substring(0, fieldSelectSql.LastIndexOf(",")) + " from ";
            if (voucherTotalInfo.TableConnectSql != "")
            {
                fieldSelectSql = fieldSelectSql + voucherTotalInfo.TableConnectSql;
            }
            else
            {
                fieldSelectSql = fieldSelectSql + voucherTotalInfo.MainTable;
            }
            TableDicInfo currTableDicInfo = DictionaryAccessFacade.GetTableDicInfo(voucherTotalInfo.MainTable);
            fieldSelectSql = fieldSelectSql + " where " + currTableDicInfo.TableCode + "." + currTableDicInfo.PrimaryField + " = ";
            return fieldSelectSql;
        }

        /// <summary>
        /// 获取要删除的数据，以DataSet的形式传出去
        /// </summary>
        /// <returns></returns>
        public System.Data.DataSet GetDeleteDSData(string pkValues)
        {
            try
            {
                if (string.IsNullOrEmpty(pkValues))
                {
                    throw new ArgumentNullException("Please select the record");
                }
                //产生dataset
                System.Data.DataSet dsInfo = GenerateDSStruct();
                //产生字段选择语句
                string fieldSelectSql = GenerateFieldSelectSql();
                int i = 0;
                string tableCode = "", fieldCode = "";
                foreach (string pkValue in System.Text.RegularExpressions.Regex.Split(pkValues, ","))
                {
                    AddDSNewRow(dsInfo);
                    //步骤1，将数据操作状态保存到dataset中
                    foreach (DataTable dtInfo in dsInfo.Tables)
                    {
                        dtInfo.Rows[i]["RowStatus"] = "3";
                    }

                    //步骤3，将关联的表信息添加到DataSet中
                    if (fieldSelectSql != "")
                    {
                        fieldSelectSql = fieldSelectSql + "'" + pkValue + "'";
                        DataTable dtInfo = UCListDALService.DBHelper.ExecuteDataSet(fieldSelectSql).Tables[0];

                        //加入到DataTable
                        foreach (DataColumn dcInfo in dtInfo.Columns)
                        {
                            tableCode = dcInfo.ColumnName.Substring(0, dcInfo.ColumnName.IndexOf("."));
                            fieldCode = dcInfo.ColumnName.Substring(dcInfo.ColumnName.IndexOf(".") + 1);
                            dsInfo.Tables[tableCode].Rows[i][fieldCode] = dtInfo.Rows[0][dcInfo.ColumnName];
                        }
                    }
                    i++;
                }
                return dsInfo;
            }
            catch
            {
                return null;
            }
        }

        private void SetTablePrimaryKey(DataTable dtInfo)
        {
            string tableCode = dtInfo.TableName;
            TableDicInfo tableDicInfo = DictionaryAccessFacade.GetTableDicInfo(tableCode);
            if (tableDicInfo == null)
            {
                return;
            }
            string primaryKeyField = tableDicInfo.PrimaryField;
            dtInfo.PrimaryKey = new DataColumn[] { dtInfo.Columns[primaryKeyField] };
        }
        #endregion

        #region Public Method

        /// <summary>
        /// 获取选中行的主键值
        /// </summary>
        /// <returns></returns>
        public string GetListCheckedPrimaryValues()
        {
            string primaryValues = "";
            if (ViewState["dtList"] == null)
            {
                return null;
            }
            for (int i = 0; i < gvList.Rows.Count; i++)
            {
                System.Web.UI.WebControls.CheckBox cbChecked;
                cbChecked = (System.Web.UI.WebControls.CheckBox)gvList.Rows[i].FindControl("chkSel");
                if (cbChecked.Checked == true)
                {
                    if (string.IsNullOrEmpty(primaryValues))
                    {
                        primaryValues = gvList.DataKeys[i].Value.ToString().Trim();
                    }
                    else
                    {
                        primaryValues = primaryValues + "," + gvList.DataKeys[i].Value.ToString().Trim();
                    }
                }
            }
            return primaryValues;
        }

        /// <summary>
        /// 获取单据标题
        /// </summary>
        /// <param name="voucherID"></param>
        /// <returns></returns>
        private string GetVoucherListTitle(string voucherID)
        {
            VoucherTotalResInfo voucherTotalResInfo = DictionaryAccessFacade.GetVoucherTotalResInfo(voucherID);
            if (voucherTotalResInfo == null)
            {
                return "";
            }
            else
            {
                return voucherTotalResInfo.TotalInfoDesc;
            }
        }

        /// <summary>
        /// 刷新列表
        /// </summary>
        public void RefreshList()
        {
            ViewState["dtList"] = null;
            BindVoucherListData();
        }


        /// <summary>
        /// 给导出提供的数据接口
        /// </summary>
        /// <returns></returns>
        public DataSet GetExportData()
        {

            VoucherTotalInfo voucherTotalInfo = DictionaryAccessFacade.GetVoucherTotalInfo(VoucherID);
            string selectSql = ""; string fromSql = "";
            if (string.IsNullOrEmpty(voucherTotalInfo.TableConnectSql))
            {
                fromSql = voucherTotalInfo.MainTable;
            }
            else
            {
                fromSql = voucherTotalInfo.TableConnectSql;
            }
            int columnIndex = 0;
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            voucherListItems.ForSpecification<CVoucherListItemInfo>(
                  delegate(CVoucherListItemInfo voucherListItemInfo)
                  {
                      UCListDALService.GenerateListSql(voucherListItemInfo, ref selectSql, ref fromSql, ref columnIndex, dictionary);
                  },
                  delegate(CVoucherListItemInfo voucherListItemInfo)
                  {
                      return voucherListItemInfo.Show == true ? true : false;
                  }
                );
            selectSql = selectSql.Substring(0, selectSql.Length - 1);
            string whereSql = GetWhereSql();
            string orderSql = GetOrderSql(voucherTotalInfo.OrderSql.ToString().Trim());

            int recordCount = 0;
            DataTable dtListDataInfo = UCListDALService.GetExportData(selectSql, fromSql, whereSql, this.gvList.PageIndex, this.gvList.PageSize, out recordCount, orderSql);
            dtListDataInfo.TableName = DictionaryAccessFacade.GetVoucherTotalResInfo(VoucherID).TotalInfoDesc;
            System.Data.DataSet dsListInfo = new DataSet();
            dsListInfo.Tables.Add(dtListDataInfo);
            return dsListInfo;
        }
        #endregion

        #region 设置加密列

        private void SetEncryptColumn(DataTable dtPageData)
        {
            if (!string.IsNullOrEmpty(this.EncryptColumnFields))
            {
                string[] arrEncryptColumnFields = this.EncryptColumnFields.Split(',');

                foreach (DataRow dr in dtPageData.Rows)
                {
                    if (dr.RowState != DataRowState.Deleted)
                    {
                        foreach (string EncryptColumnField in arrEncryptColumnFields)
                        {
                            if (!string.IsNullOrEmpty(EncryptColumnField))
                            {
                                string[] fieldInfo = EncryptColumnField.Split('.');
                                if (fieldInfo.Length == 2)
                                {
                                    string tableCode = fieldInfo[0];
                                    string fieldCode = fieldInfo[1];
                                    if (dtPageData.Columns.Contains(tableCode + "__" + fieldCode))
                                    {
                                        dr[tableCode + "__" + fieldCode] = "******";
                                    }

                                    if (dtPageData.Columns.Contains(tableCode + "." + fieldCode))
                                    {
                                        dr[tableCode + "." + fieldCode] = "******";
                                    }

                                }
                            }

                        }
                    }
                }
            }
        }

        #endregion
    }
}
